<?php
namespace App\Logic\ZiNiao\Api;

use App\Libs\ZiNiao\Request\AuthStoresRequest;
use App\Libs\ZiNiao\RequireOpenClient;
use App\Libs\ZiNiao\RequireUserToken;
use Exception;
class GetAuthStores
{
    /**
     * 获取当前用户可访问店铺
     * @param $bizContent  ['userCode' => "XXXXXX"]
     * @return int
     */
    public function exe($bizContent)
    {
        $openClient = RequireOpenClient::getInstance();
        $requireUserToken = new RequireUserToken();
        $userToken = $requireUserToken->getUserToken($openClient,$bizContent);
        $request = new AuthStoresRequest();
        $result = $openClient->executeUserToken($request,$userToken);// 发送请求
        $result_decode = json_decode($result);dd($result_decode);
        if (($result_decode->code === 0 or $result_decode->code === '0') and !isset($result_decode->sub_code)) {
            $data = $result_decode->data;dd($data);
            if ($data->code === 0 or $data->code === '0') {
                return $data->data;
            }else{
                report(new Exception('GetAuthStores失败:' . $data->msg,230));
                return 0;
            }
        }else {
            report(new Exception('GetAuthStores失败:' . $result,230));
            return 0;
        }
    }
}
